package com.controller;

import com.model.HotBarrage;
import com.model.MyUser;
import com.model.SendTimes;
import com.model.Sort;
import com.server.HotBarrageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api("热门榜单内弹幕")
@RestController
@RequestMapping("/hotBarrage")
public class HotBarrageController {

    @Autowired
    private HotBarrageService hotBarrageService;

    @CrossOrigin
    @RequestMapping(value = "/addHotBarrage", produces = "application/json;charset=utf-8", method = RequestMethod.PUT)
    public int insertHotBarrage(@RequestBody HotBarrage hotBarrage){
        System.out.println("进入弹幕添加方法");
        return hotBarrageService.insertHotBarrage(hotBarrage);
    }

    @CrossOrigin
    @RequestMapping(value = "/getHotBarrage", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
    public HotBarrage getHotBarrage(int id){
        System.out.println("进入根据主键查找弹幕方法");
        return hotBarrageService.getHotBarrage(id);
    }

    @CrossOrigin
    @RequestMapping(value = "/updateHotBarrage", produces = "application/json;charset=utf-8", method = RequestMethod.PUT)
    public int updateHotBarrage(@RequestBody HotBarrage hotBarrage){
        System.out.println("进入弹幕修改方法, 修改的主键为: " + hotBarrage.getId());
        return hotBarrageService.updateHotBarrage(hotBarrage);
    }

    @CrossOrigin
    @RequestMapping(value = "/deleteHotBarrage", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
    public int deleteHotBarrage(int id){
        System.out.println("进入弹幕删除方法, 主键为" + id);
        return hotBarrageService.deleteHotBarrage(id);
    }

    @CrossOrigin
    @RequestMapping(value = "/getAllHotBarrage", produces = "application/json;charset=utf-8", method = RequestMethod.PUT)
    public List<HotBarrage> getAllHotBarrage(@RequestBody HotBarrage hotBarrage){
        System.out.println("进入弹幕查询方法");
        return hotBarrageService.getAllHotBarrage(hotBarrage);
    }
    @ApiOperation(value = "重复弹幕排序")
    @GetMapping("/barrageSort")
    @CrossOrigin
    public List<Sort> barrageSort() {
        return hotBarrageService.barrageSort();
    }

    @ApiOperation(value = "弹幕bv号排序")
    @GetMapping("/bvSort")
    @CrossOrigin
    public List<Sort> bvSort() {
        return hotBarrageService.bvSort();
    }

    @CrossOrigin
    @RequestMapping(value = "/getSendTimes", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
    public List<SendTimes> barrageSendTime(String bvid){
        System.out.println("进入过去弹幕发送时间方法, bv号为: " + bvid);
        return hotBarrageService.barrageSendTime(bvid);
    }

    @CrossOrigin
    @RequestMapping(value = "/getContents", produces = "application/json;charset=utf-8", method = RequestMethod.GET)
    public List<String> hotBarrageContent(String bvid){
        System.out.println("进入获取弹幕内容方法, bv号为: " + bvid);
        return hotBarrageService.hotBarrageContent(bvid);
    }
}
